﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Coronox.SkyShell;
using System.Text.RegularExpressions;

namespace SkyShellExTestForm
{
    public partial class WLLoginBrowserWindowTest : Form
    {
        public WLLoginBrowserWindowTest()
        {
            InitializeComponent();
            webBrowser.Navigate(SkyDriveAction.SignInUrl);
        }

        private void webBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            
            if (e.Url.AbsoluteUri.Contains("code="))
            {
                SkyDriveAction.AuthCode = Regex.Split(e.Url.AbsoluteUri, "code=")[1];
                SkyDriveAction.GetAccessTokenAndRefreshToken();
                this.Close();
            }
        }
    }
}
